package cn.bd13.demoredis.utils;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

public class TokenUtils {

    public static String createToken(String userInfo){
        //常规来说包括5部分
        //token-PC-32位加密信息-时间信息-6位随机数
        StringBuilder builder=new StringBuilder();
        builder.append("token-");
        builder.append("PC-");
        String info=MD5.getMD5(userInfo,32);
        builder.append(info+"-");
        builder.append(new SimpleDateFormat("yyyyMMddHHmmsss").format(new Date()));
        builder.append(UUID.randomUUID().toString().substring(0,6));
        return builder.toString();
    }

    public static void main(String[] args) {
        String token = createToken("zhangsan");
        System.out.println(token);
    }


}
